import Dummy from 'dummyjs';
// min ≤ r ≤ max
function random(Min, Max) {
  var Range = Max - Min;
  var Rand = Math.random();
  var num = Min + Math.round(Rand * Range); //四舍五入
  return num;
}
export const mockData = (page, pageSize, w = 160 * 3, h = 90 * 3, payload: any[] = []) => {
  const datas: any[] = [];
  for (let i = 0; i < pageSize; i++) {
    let data: any = {};

    // 随机取
    const r = random(0, payload.length - 1);
    const others: any = payload[r] || {};

    data.id = 'mock-' + i + 'page' + page;
    data.title = 'Card#' + i;
    data.content = Dummy.text(20, 20);
    data.collapsed = true;
    const newData = {
      ...data,
      ...others,
    };
    datas.push(newData);
  }

  return datas;
};
